<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">

    <title>Document</title>
    <style>
           .demo{
               width: 80px;
               background: pink;
               position: absolute;
               left:0;
               top:100px;
           }
    </style>
</head>

<body>


    <div class="demo">
          demo
    </div>
    
    <script>
        var oDemo = document.getElementsByClassName('demo')[0];
        var time2;

        function move() {
            console.log('999999')
            var l = oDemo.offsetLeft;
            if (l < 1000) {
                oDemo.style.left = l + 10 + 'px';
                setTimeout(move, 100);
            } else {
                oDemo.style.left = '1000px';
            }

        }
        move();


    </script>
</body>

</html>